import Tools from '../../../../utils/Tools.ts';
import { Text, View } from 'native-base';
import { CommonStyle } from '../../../../common/commonStyle.ts';
import React from 'react';

export default function RenderPrice(item: IProductInformation, shoppingCart: IProductInformation[], fontSize?: number) {
  if (Tools.hasActiveRange(item, shoppingCart)) {
    return (
      <View flexDirection={'row'} alignItems={'center'}>
        <Text fontWeight={'bold'} fontSize={fontSize || 12} color={CommonStyle.price}>
          ¥{item.active.activePrice}
        </Text>
        <Text ml={2} fontSize={fontSize || 12} textDecorationLine={'line-through'}>
          ¥{item.price}
        </Text>
      </View>
    );
  } else {
    return (
      <View flexDirection={'row'} alignItems={'center'}>
        <Text fontWeight={'bold'} fontSize={fontSize || 12} color={CommonStyle.price}>
          ¥{item.salePrice}
        </Text>
        {item.salePrice !== item.price && (
          <Text ml={2} mt={0.5} fontSize={fontSize || 12} textDecorationLine={'line-through'}>
            ¥{item.price}
          </Text>
        )}
      </View>
    );
  }
}
